<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>TensorRT实战教程 | 啊粥啊周舟の部落阁</title><meta name="author" content="Zhouwy"><meta name="copyright" content="Zhouwy"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="TensorRT实战教程一、开发环境搭建1.1 安装CUDANvidia-CUDA下载地址：https:&#x2F;&#x2F;developer.nvidia.com&#x2F;cuda-downloads  在命令行中输入： 12wget https:&#x2F;&#x2F;developer.download.nvidia.com&#x2F;compute&#x2F;cuda&#x2F;11.7.1&#x2F;local_installers&#x2F;cuda_11.7.1_515.65">
<meta property="og:type" content="article">
<meta property="og:title" content="TensorRT实战教程">
<meta property="og:url" content="https://gitee.com/zwyywz/zwyywz.git/2022/05/22/TensorRT%E6%95%99%E7%A8%8B/index.html">
<meta property="og:site_name" content="啊粥啊周舟の部落阁">
<meta property="og:description" content="TensorRT实战教程一、开发环境搭建1.1 安装CUDANvidia-CUDA下载地址：https:&#x2F;&#x2F;developer.nvidia.com&#x2F;cuda-downloads  在命令行中输入： 12wget https:&#x2F;&#x2F;developer.download.nvidia.com&#x2F;compute&#x2F;cuda&#x2F;11.7.1&#x2F;local_installers&#x2F;cuda_11.7.1_515.65">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://blog-1300216920.cos.ap-nanjing.myqcloud.com/FI-1.png">
<meta property="article:published_time" content="2022-05-22T01:25:00.000Z">
<meta property="article:modified_time" content="2023-04-16T13:04:53.756Z">
<meta property="article:author" content="Zhouwy">
<meta property="article:tag" content="DeepLearning">
<meta property="article:tag" content="C&#x2F;C++">
<meta property="article:tag" content="TensorRT">
<meta property="article:tag" content="CUDA">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://blog-1300216920.cos.ap-nanjing.myqcloud.com/FI-1.png"><link rel="shortcut icon" href="/zwyywz/img/favicon.png"><link rel="canonical" href="https://gitee.com/zwyywz/zwyywz.git/2022/05/22/TensorRT%E6%95%99%E7%A8%8B/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/zwyywz/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/zwyywz/',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":300},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: Zhouwy","link":"链接: ","source":"来源: 啊粥啊周舟の部落阁","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'TensorRT实战教程',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-04-16 21:04:53'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="///at.alicdn.com/t/c/font_4018630_wl3l75i04vl.css"><meta name="generator" content="Hexo 6.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/zwyywz/img/avatar.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/zwyywz/archives/"><div class="headline">文章</div><div class="length-num">17</div></a><a href="/zwyywz/tags/"><div class="headline">标签</div><div class="length-num">29</div></a><a href="/zwyywz/categories/"><div class="headline">分类</div><div class="length-num">5</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/zwyywz/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/zwyywz/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/zwyywz/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 分类</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/zwyywz/note/"><i class="fa-fw iconfont icon-xuexibiji"></i><span> 学习笔记</span></a></li><li><a class="site-page child" href="/zwyywz/opensource/"><i class="fa-fw iconfont icon-xiangmu"></i><span> 开源项目</span></a></li><li><a class="site-page child" href="/zwyywz/development/"><i class="fa-fw iconfont icon-peizhi-xitongpeizhi"></i><span> 环境配置</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/zwyywz/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/zwyywz/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/zwyywz/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/zwyywz/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://blog-1300216920.cos.ap-nanjing.myqcloud.com/FI-1.png')"><nav id="nav"><span id="blog-info"><a href="/zwyywz/" title="啊粥啊周舟の部落阁"><span class="site-name">啊粥啊周舟の部落阁</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/zwyywz/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/zwyywz/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/zwyywz/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 分类</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/zwyywz/note/"><i class="fa-fw iconfont icon-xuexibiji"></i><span> 学习笔记</span></a></li><li><a class="site-page child" href="/zwyywz/opensource/"><i class="fa-fw iconfont icon-xiangmu"></i><span> 开源项目</span></a></li><li><a class="site-page child" href="/zwyywz/development/"><i class="fa-fw iconfont icon-peizhi-xitongpeizhi"></i><span> 环境配置</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/zwyywz/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/zwyywz/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/zwyywz/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/zwyywz/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">TensorRT实战教程</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-05-22T01:25:00.000Z" title="发表于 2022-05-22 09:25:00">2022-05-22</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-04-16T13:04:53.756Z" title="更新于 2023-04-16 21:04:53">2023-04-16</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/zwyywz/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="TensorRT实战教程"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="TensorRT实战教程"><a href="#TensorRT实战教程" class="headerlink" title="TensorRT实战教程"></a>TensorRT实战教程</h1><h2 id="一、开发环境搭建"><a href="#一、开发环境搭建" class="headerlink" title="一、开发环境搭建"></a>一、开发环境搭建</h2><h3 id="1-1-安装CUDA"><a href="#1-1-安装CUDA" class="headerlink" title="1.1 安装CUDA"></a>1.1 安装CUDA</h3><p>Nvidia-CUDA下载地址：<a target="_blank" rel="noopener" href="https://developer.nvidia.com/cuda-downloads">https://developer.nvidia.com/cuda-downloads</a></p>
<p><img src="https://blog-1300216920.cos.ap-nanjing.myqcloud.com/image-20220902092137881.png" alt=""></p>
<p>在命令行中输入：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run</span><br><span class="line">sudo sh cuda_11.7.1_515.65.01_linux.run</span><br></pre></td></tr></table></figure>
<h3 id="1-2-安装CUDNN"><a href="#1-2-安装CUDNN" class="headerlink" title="1.2 安装CUDNN"></a>1.2 安装CUDNN</h3><h3 id="1-3-下载TensorRT"><a href="#1-3-下载TensorRT" class="headerlink" title="1.3 下载TensorRT"></a>1.3 下载TensorRT</h3><h2 id="二、推理引擎开发"><a href="#二、推理引擎开发" class="headerlink" title="二、推理引擎开发"></a>二、推理引擎开发</h2><h3 id="2-1-前期准备工作（定义通用数据结构和辅助函数）"><a href="#2-1-前期准备工作（定义通用数据结构和辅助函数）" class="headerlink" title="2.1 前期准备工作（定义通用数据结构和辅助函数）"></a>2.1 前期准备工作（定义通用数据结构和辅助函数）</h3><p>定义一些通用的数据结构来方便数据的上传和校验，比如输入输出的张量的维度、大小、名字、类型……以及一些控制流程的结构。这个文件命名为==my_common.h==，可以移植到任意工程，是只需要写一次的文件。</p>
<ul>
<li>设置导入模型的参数</li>
</ul>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">typedef</span> <span class="keyword">struct</span></span><br><span class="line">&#123;</span><br><span class="line">    <span class="type">char</span> visibleCard[<span class="number">32</span>];     <span class="comment">//设置哪些ＧＰＵ卡是可见的</span></span><br><span class="line">    <span class="type">int</span> gpu_id;               <span class="comment">//虚拟的gpu id</span></span><br><span class="line">    <span class="type">char</span> model_path[<span class="number">256</span>];     <span class="comment">//模型的路径名</span></span><br><span class="line">    MY_BOOL bIsCipher;            <span class="comment">//模型文件是否加密</span></span><br><span class="line">    <span class="type">int</span> encStartPoint;</span><br><span class="line">    <span class="type">int</span> encLength;</span><br><span class="line">    <span class="type">int</span> maxBatchSize;</span><br><span class="line">    <span class="type">bool</span> bInt8;</span><br><span class="line">    <span class="type">bool</span> bInt16;</span><br><span class="line">&#125; <span class="type">model_params_t</span>;</span><br></pre></td></tr></table></figure>
<ul>
<li>设置数据输入输出数据类型</li>
</ul>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">typedef</span> <span class="keyword">enum</span></span><br><span class="line">&#123;</span><br><span class="line">    DT_INVALID = <span class="number">0</span>,</span><br><span class="line">    DT_FLOAT = <span class="number">1</span>,</span><br><span class="line">    DT_DOUBLE = <span class="number">2</span>,</span><br><span class="line">    DT_INT32 = <span class="number">3</span>,</span><br><span class="line">    DT_UINT8 = <span class="number">4</span>,</span><br><span class="line">    DT_INT16 = <span class="number">5</span>,</span><br><span class="line">    DT_INT8 = <span class="number">6</span>,</span><br><span class="line">    DT_STRING = <span class="number">7</span>,</span><br><span class="line">    DT_INT64 = <span class="number">9</span>,</span><br><span class="line">    DT_BOOL = <span class="number">10</span>,</span><br><span class="line">&#125; <span class="type">tensor_types_t</span>;</span><br></pre></td></tr></table></figure>
<ul>
<li>设置输入输出数据的参数</li>
</ul>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">typedef</span> <span class="keyword">struct</span></span><br><span class="line">&#123;</span><br><span class="line">    <span class="type">tensor_types_t</span> type;   <span class="comment">//Tensor的类型</span></span><br><span class="line">    <span class="type">char</span> aTensorName[<span class="number">256</span>]; <span class="comment">//Tensor的名字</span></span><br><span class="line">    <span class="type">int</span> nDims;             <span class="comment">//Tensor的rank</span></span><br><span class="line">    <span class="type">int</span> pShape[<span class="number">4</span>];         <span class="comment">//shape</span></span><br><span class="line">    <span class="type">int</span> nElementSize;      <span class="comment">//多少个元素</span></span><br><span class="line">    <span class="type">int</span> nLength;           <span class="comment">//多少个字节长度</span></span><br><span class="line">&#125; <span class="type">tensor_params_t</span>;</span><br></pre></td></tr></table></figure>
<p>完整代码：</p>
<h3 id="2-2-定义推理引擎类接口（my-interface-h）"><a href="#2-2-定义推理引擎类接口（my-interface-h）" class="headerlink" title="2.2 定义推理引擎类接口（my_interface.h）"></a>2.2 定义推理引擎类接口（my_interface.h）</h3><p>1、首先，定一个名为==“MyTrtEngine”==的模板类，其中包含一个智能指针。在定义一个名为==MyEngineParams==的数据结构，存储Engine的参数信息。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">struct</span> <span class="title class_">MyEngineParams</span> &#123;</span><br><span class="line">    <span class="type">int</span> gpu_id&#123;<span class="number">0</span>&#125;;</span><br><span class="line">    <span class="type">int</span> maxBatchSize&#123;<span class="number">1</span>&#125;;</span><br><span class="line">    <span class="type">int</span> dlaCore&#123;<span class="number">-1</span>&#125;;</span><br><span class="line">    <span class="type">bool</span> int8&#123;<span class="literal">false</span>&#125;;</span><br><span class="line">    <span class="type">bool</span> fp16&#123;<span class="literal">false</span>&#125;;</span><br><span class="line">    <span class="type">bool</span> bIsEncription&#123;<span class="literal">false</span>&#125;;</span><br><span class="line">    <span class="type">int</span> encStartPoint&#123;<span class="number">0</span>&#125;;</span><br><span class="line">    <span class="type">int</span> encLength&#123;<span class="number">-1</span>&#125;;</span><br><span class="line"></span><br><span class="line">    std::vector&lt;std::string&gt; inputTensorNames;</span><br><span class="line">    std::vector&lt;std::string&gt; outputTensorNames;</span><br><span class="line"></span><br><span class="line">    std::string trtFileName;   <span class="comment">//输入文件的路径</span></span><br><span class="line">&#125;;</span><br><span class="line"><span class="keyword">class</span> <span class="title class_">MyTrtEngine</span> &#123;</span><br><span class="line">    <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</span><br><span class="line">    <span class="keyword">using</span> MyTrtUniquePtr = std::unique_ptr&lt;T, samplesCommon::InferDeleter&gt;;</span><br><span class="line">  <span class="keyword">public</span>:</span><br><span class="line">  	……</span><br><span class="line">  <span class="keyword">private</span>:</span><br><span class="line">  	……</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>2、设置==MyTrtEngine==的私有属性，包括导入模型的参数==mParams==，输入输出数据的维度==mInputDims，mOutputDims==，输出的数据的类别（mnist数据集是十类）==mNumber==，导入的模型==mEngine==，输入输出的数据==mInputTensorArray，mOutTensorArray==。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">private</span>:</span><br><span class="line">    MyEngineParams mParams;</span><br><span class="line">    nvinfer1::Dims mInputDims[<span class="number">16</span>];</span><br><span class="line">    nvinfer1::Dims mOutputDims[<span class="number">16</span>];</span><br><span class="line">    <span class="type">int</span> mNumber&#123;<span class="number">0</span>&#125;;</span><br><span class="line"></span><br><span class="line">    std::shared_ptr&lt;nvinfer1::ICudaEngine&gt; mEngine;</span><br><span class="line">    <span class="type">tensor_array_t</span> *mInputTensorArray;</span><br><span class="line">    <span class="type">tensor_array_t</span> *mOutTensorArray;</span><br></pre></td></tr></table></figure>
<p>3、设置==MytrtEngine==的私有方法，包括导入模型方法==loadEngine==，获取模型信息==getInfoFromCudaEngine==，读取输入==processInput==，获得输出==getOutputTensor==。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">private</span>:</span><br><span class="line">    <span class="function">ICudaEngine *<span class="title">loadEngine</span><span class="params">(<span class="type">const</span> std::string &amp;engine, <span class="type">int</span> DLACore, std::ostream &amp;err)</span></span>;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="type">bool</span> <span class="title">getInfoFromCudaEngine</span><span class="params">()</span></span>;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="type">bool</span> <span class="title">processInput</span><span class="params">(<span class="type">const</span> samplesCommon::BufferManager &amp;buffers)</span></span>;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="type">bool</span> <span class="title">getOutputTensor</span><span class="params">(<span class="type">const</span> samplesCommon::BufferManager &amp;buffers)</span></span>;</span><br></pre></td></tr></table></figure>
<p>4、设置==MytrtEngine==公开方法</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    <span class="function"><span class="keyword">explicit</span> <span class="title">MyTrtEngine</span><span class="params">(<span class="type">model_params_t</span> &amp;params)</span></span>;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="type">void</span> <span class="title">setInputTensorArray</span><span class="params">(<span class="type">tensor_array_t</span> *input_tensor_array)</span> </span>&#123; mInputTensorArray = input_tensor_array; &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="type">void</span> <span class="title">setOutputTensorArray</span><span class="params">(<span class="type">tensor_array_t</span> *output_tensor_array)</span> </span>&#123; mOutTensorArray = output_tensor_array; &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="type">result_t</span> <span class="title">openTrtModel</span><span class="params">()</span></span>;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="type">result_t</span> <span class="title">releaseTrtModel</span><span class="params">()</span></span>;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="type">result_t</span> <span class="title">infer</span><span class="params">()</span></span>;</span><br></pre></td></tr></table></figure>
<h3 id="2-3-实现推理引擎（my-interface-cpp）"><a href="#2-3-实现推理引擎（my-interface-cpp）" class="headerlink" title="2.3 实现推理引擎（my_interface.cpp）"></a>2.3 实现推理引擎（my_interface.cpp）</h3><p>1、实现loadEngine方法：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"><span class="function">nvinfer1::ICudaEngine *<span class="title">MyTrtEngine::loadEngine</span><span class="params">(std::string &amp;engine, <span class="type">int</span> DLACore, std::ostream &amp;err)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">initLibNvInferPlugins</span>(&amp;sample::gLogger.<span class="built_in">getTRTLogger</span>(), <span class="string">&quot;&quot;</span>);</span><br><span class="line">    <span class="comment">//如果加密了</span></span><br><span class="line">  	<span class="keyword">if</span> (mParms.bIsEncription) &#123;</span><br><span class="line">        FILE *f_pb_in = <span class="built_in">fopen</span>(engine.<span class="built_in">c_str</span>(), <span class="string">&quot;rb&quot;</span>);</span><br><span class="line">        <span class="keyword">if</span> (<span class="literal">NULL</span> == f_pb_in) &#123;</span><br><span class="line">            std::cout &lt;&lt; <span class="string">&quot;[Error] Load encryption engine :&quot;</span> &lt;&lt; engine &lt;&lt; <span class="string">&quot;is failed&quot;</span> &lt;&lt; std::endl;</span><br><span class="line">            <span class="built_in">exit</span>(<span class="number">-1</span>);</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            std::cout &lt;&lt; <span class="string">&quot;[info] Open encryption engine :&quot;</span> &lt;&lt; engine &lt;&lt; std::endl;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/*解密相关*/</span></span><br><span class="line">        <span class="type">int</span> enStartPoint = mParms.encStartPoint / <span class="number">16</span>;</span><br><span class="line">        <span class="type">int</span> encLength = mParms.encLength / <span class="number">16</span>;</span><br><span class="line">				<span class="comment">//encryption::DecryptionModelPartial在ase.h中</span></span><br><span class="line">        std::string strOutFileContent = encryption::<span class="built_in">DecryptionModelPartial</span>(engine, enStartPoint, encLength);</span><br><span class="line">        <span class="keyword">if</span> (!f_pb_in) &#123;</span><br><span class="line">            <span class="built_in">fclose</span>(f_pb_in);</span><br><span class="line">        &#125;</span><br><span class="line">      	<span class="comment">//智能指针：</span></span><br><span class="line">        MyTrtUniquePtr&lt;IRuntime&gt; runtime&#123;<span class="built_in">createInferRuntime</span>(sample::gLogger.<span class="built_in">getTRTLogger</span>())&#125;;</span><br><span class="line">        <span class="keyword">if</span> (mParms.dlaCore != <span class="number">-1</span>) &#123;</span><br><span class="line">            runtime-&gt;<span class="built_in">setDLACore</span>(mParms.dlaCore);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> runtime-&gt;<span class="built_in">deserializeCudaEngine</span>(strOutFileContent.<span class="built_in">data</span>(), strOutFileContent.<span class="built_in">size</span>(), <span class="literal">nullptr</span>);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        std::ifstream <span class="built_in">engineFile</span>(engine, std::ios::binary);</span><br><span class="line">        <span class="keyword">if</span> (!engineFile) &#123;</span><br><span class="line">            std::cout &lt;&lt; <span class="string">&quot;[Error] Load encryption engine :&quot;</span> &lt;&lt; engine &lt;&lt; <span class="string">&quot;is failed&quot;</span> &lt;&lt; std::endl;</span><br><span class="line">            <span class="built_in">exit</span>(<span class="number">-1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        engineFile.<span class="built_in">seekg</span>(<span class="number">0</span>, engineFile.end);</span><br><span class="line">        <span class="type">long</span> <span class="type">int</span> fileSize = engineFile.<span class="built_in">tellg</span>();</span><br><span class="line">        engineFile.<span class="built_in">seekg</span>(<span class="number">0</span>, engineFile.beg);</span><br><span class="line"></span><br><span class="line">        <span class="function">std::vector&lt;<span class="type">char</span>&gt; <span class="title">engineData</span><span class="params">(fileSize)</span></span>;</span><br><span class="line">        engineFile.<span class="built_in">read</span>(engineData.<span class="built_in">data</span>(), fileSize);</span><br><span class="line">        <span class="keyword">if</span> (!engineFile) &#123;</span><br><span class="line">            std::cout &lt;&lt; <span class="string">&quot;[Error] Error Load engine data :&quot;</span> &lt;&lt; engine &lt;&lt; std::endl;</span><br><span class="line">            <span class="built_in">exit</span>(<span class="number">-1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        MyTrtUniquePtr&lt;IRuntime&gt; runtime&#123;<span class="built_in">createInferRuntime</span>(sample::gLogger.<span class="built_in">getTRTLogger</span>())&#125;;</span><br><span class="line">        <span class="keyword">if</span> (mParms.dlaCore != <span class="number">-1</span>) &#123;</span><br><span class="line">            runtime-&gt;<span class="built_in">setDLACore</span>(mParms.dlaCore);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> runtime-&gt;<span class="built_in">deserializeCudaEngine</span>(engineData.<span class="built_in">data</span>(), fileSize, <span class="literal">nullptr</span>);</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="三、模型转换"><a href="#三、模型转换" class="headerlink" title="三、模型转换"></a>三、模型转换</h2></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://gitee.com/zwyywz/zwyywz.git">Zhouwy</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://gitee.com/zwyywz/zwyywz.git/2022/05/22/TensorRT%E6%95%99%E7%A8%8B/">https://gitee.com/zwyywz/zwyywz.git/2022/05/22/TensorRT%E6%95%99%E7%A8%8B/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://gitee.com/zwyywz/zwyywz.git" target="_blank">啊粥啊周舟の部落阁</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/zwyywz/tags/DeepLearning/">DeepLearning</a><a class="post-meta__tags" href="/zwyywz/tags/C-C/">C/C++</a><a class="post-meta__tags" href="/zwyywz/tags/TensorRT/">TensorRT</a><a class="post-meta__tags" href="/zwyywz/tags/CUDA/">CUDA</a></div><div class="post_share"><div class="social-share" data-image="https://blog-1300216920.cos.ap-nanjing.myqcloud.com/FI-1.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/zwyywz/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" src="/zwyywz/img/wechat.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/zwyywz/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" src="/zwyywz/img/alipay.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/zwyywz/2022/06/15/%E5%9F%BA%E4%BA%8EOpenCV%E5%92%8CC++%E8%BD%A6%E9%81%93%E7%BA%BF%E6%A3%80%E6%B5%8B/" title="基于OpenCV和C++车道线检测"><img class="cover" src="https://blog-1300216920.cos.ap-nanjing.myqcloud.com/weixin15937410430092-20230410105251467.png" onerror="onerror=null;src='/zwyywz/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">基于OpenCV和C++车道线检测</div></div></a></div><div class="next-post pull-right"><a href="/zwyywz/2021/06/21/YOLO%E5%8E%9F%E7%90%86%E8%AF%A6%E8%A7%A3/" title="【YOLOv5】原理详解"><img class="cover" src="https://blog-1300216920.cos.ap-nanjing.myqcloud.com/yolo.jpg" onerror="onerror=null;src='/zwyywz/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">【YOLOv5】原理详解</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/zwyywz/2020/09/20/Mac%20M1%20Pro%20%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" title="Mac M1 Pro 深度学习环境搭建"><img class="cover" src="https://blog-1300216920.cos.ap-nanjing.myqcloud.com/apple-macbook-pro-m1-2020-5-20230410110609763.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-09-20</div><div class="title">Mac M1 Pro 深度学习环境搭建</div></div></a></div><div><a href="/zwyywz/2023/04/15/%E5%9C%A8ubuntu%E4%B8%8A%E4%BB%8E0%E5%BC%80%E5%A7%8B%E9%85%8D%E7%BD%AE%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83/" title="在Ubuntu上从0开始配置深度学习开发环境"><img class="cover" src="https://cdn.educba.com/academy/wp-content/uploads/2020/01/Deep-Learning.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-04-15</div><div class="title">在Ubuntu上从0开始配置深度学习开发环境</div></div></a></div><div><a href="/zwyywz/2021/06/15/%E5%9F%BA%E4%BA%8E%E6%9C%BA%E5%99%A8%E8%A7%86%E8%A7%89%E7%9A%84%E4%BB%BF%E7%94%9F%E6%9C%BA%E6%A2%B0%E6%89%8B%E6%8E%8C/" title="基于机器视觉的机械手掌"><img class="cover" src="https://blog-1300216920.cos.ap-nanjing.myqcloud.com/yolo.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-06-15</div><div class="title">基于机器视觉的机械手掌</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#TensorRT%E5%AE%9E%E6%88%98%E6%95%99%E7%A8%8B"><span class="toc-number">1.</span> <span class="toc-text">TensorRT实战教程</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA"><span class="toc-number">1.1.</span> <span class="toc-text">一、开发环境搭建</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-%E5%AE%89%E8%A3%85CUDA"><span class="toc-number">1.1.1.</span> <span class="toc-text">1.1 安装CUDA</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-%E5%AE%89%E8%A3%85CUDNN"><span class="toc-number">1.1.2.</span> <span class="toc-text">1.2 安装CUDNN</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-3-%E4%B8%8B%E8%BD%BDTensorRT"><span class="toc-number">1.1.3.</span> <span class="toc-text">1.3 下载TensorRT</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E6%8E%A8%E7%90%86%E5%BC%95%E6%93%8E%E5%BC%80%E5%8F%91"><span class="toc-number">1.2.</span> <span class="toc-text">二、推理引擎开发</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1-%E5%89%8D%E6%9C%9F%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C%EF%BC%88%E5%AE%9A%E4%B9%89%E9%80%9A%E7%94%A8%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E5%92%8C%E8%BE%85%E5%8A%A9%E5%87%BD%E6%95%B0%EF%BC%89"><span class="toc-number">1.2.1.</span> <span class="toc-text">2.1 前期准备工作（定义通用数据结构和辅助函数）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2-%E5%AE%9A%E4%B9%89%E6%8E%A8%E7%90%86%E5%BC%95%E6%93%8E%E7%B1%BB%E6%8E%A5%E5%8F%A3%EF%BC%88my-interface-h%EF%BC%89"><span class="toc-number">1.2.2.</span> <span class="toc-text">2.2 定义推理引擎类接口（my_interface.h）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-%E5%AE%9E%E7%8E%B0%E6%8E%A8%E7%90%86%E5%BC%95%E6%93%8E%EF%BC%88my-interface-cpp%EF%BC%89"><span class="toc-number">1.2.3.</span> <span class="toc-text">2.3 实现推理引擎（my_interface.cpp）</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E6%A8%A1%E5%9E%8B%E8%BD%AC%E6%8D%A2"><span class="toc-number">1.3.</span> <span class="toc-text">三、模型转换</span></a></li></ol></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By Zhouwy</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/zwyywz/js/utils.js"></script><script src="/zwyywz/js/main.js"></script><script src="/zwyywz/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"><script>if (!window.MathJax) {
  window.MathJax = {
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"]],
      tags: 'ams'
    },
    chtml: {
      scale: 1.1
    },
    options: {
      renderActions: {
        findScript: [10, doc => {
          for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
            const display = !!node.type.match(/; *mode=display/)
            const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
            const text = document.createTextNode('')
            node.parentNode.replaceChild(text, node)
            math.start = {node: text, delim: '', n: 0}
            math.end = {node: text, delim: '', n: 0}
            doc.math.push(math)
          }
        }, ''],
        insertScript: [200, () => {
          document.querySelectorAll('mjx-container').forEach(node => {
            if (node.hasAttribute('display')) {
              btf.wrap(node, 'div', { class: 'mathjax-overflow' })
            } else {
              btf.wrap(node, 'span', { class: 'mathjax-overflow' })
            }
          });
        }, '', false]
      }
    }
  }
  
  const script = document.createElement('script')
  script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
  script.id = 'MathJax-script'
  script.async = true
  document.head.appendChild(script)
} else {
  MathJax.startup.document.state(0)
  MathJax.texReset()
  MathJax.typesetPromise()
}</script></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>